package ch.netcetera.planningpoker.client.ui.admin.create;


import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.HasKeyUpHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasVisibility;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class CreateGameView extends Composite implements
        CreateGamePresenter.IView {

    private static CreateGameViewUiBinder uiBinder = GWT
            .create(CreateGameViewUiBinder.class);

    interface CreateGameViewUiBinder extends UiBinder<Widget, CreateGameView> {
    }

    @UiField
    Button createGame;

    @UiField
    TextBox gameName;
    
    @UiField
    Image spinner;
    
    @UiField
    Label validationMessage;

    public CreateGameView() {
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Override
    public Widget asWidget() {
        return this;
    }

    @Override
    public void addToSlot(Object slot, Widget content) {

    }

    @Override
    public void removeFromSlot(Object slot, Widget content) {

    }

    @Override
    public void setInSlot(Object slot, Widget content) {

    }

    @Override
    public HasClickHandlers getCreateGame() {
        return createGame;
    }

    @Override
    public HasText getGameName() {
        return gameName;
    }

    @Override
    public void setWaiting(boolean isWaiting) {
        createGame.setEnabled(!isWaiting);
        spinner.setVisible(isWaiting);
    }

    @Override
    public HasVisibility getValidationWarning() {
        return validationMessage;
    }

    @Override
    public HasKeyUpHandlers getGameNameForEnter() {
        return gameName;
    }


}
